//
//  FRUserHelper.m
//  Live
//
//  Created by 徐芙蓉 on 2017/9/5.
//  Copyright © 2017年 Afra. All rights reserved.
//

#import "FRUserHelper.h"

@implementation FRUserHelper
+(instancetype)sharedUser
{
    static FRUserHelper *_user = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _user = [[FRUserHelper alloc] init];
    });
    return _user;
}

- (instancetype)init
{
    self = [super init];
    if (self) {

      _iconUrl =  [[NSUserDefaults standardUserDefaults] objectForKey:@"iconUrl"];
      _nickName =  [[NSUserDefaults standardUserDefaults] objectForKey:@"nickName"];
    }
    return self;
}

+(BOOL)isAutoLogin
{
    if ([FRUserHelper sharedUser].nickName.length == 0) {
        return NO;
    }
    return YES;
}

+(void)saveUser
{
    FRUserHelper *user = [FRUserHelper sharedUser];
    if (user.nickName.length != 0) {
        [[NSUserDefaults standardUserDefaults] setObject:user.nickName forKey:@"nickName"];
        [[NSUserDefaults standardUserDefaults] setObject:user.iconUrl forKey:@"iconUrl"];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }
 
}

@end
